/* 
    配置路由组件  所有组件路由跳转路径在这个文件中配置
*/

/* 使用路由懒加载(使用函数的方式)  引入组件   */
// import Home from "../pages/Home"
const Home = () => import("../pages/Home")
const Search = () => import("../pages/Search")
const Register = () => import("../pages/Register")
const Login = () => import("../pages/Login")
const Detail = () => import("../pages/Detail")
const AddCartSuccess = () => import("../pages/AddCartSuccess")
const ShopCart = () => import("../pages/ShopCart")
const Trade = () => import("../pages/Trade")
const Pay = () => import("../pages/Pay")
const PaySuccess = () => import("../pages/PaySuccess")
const MyOrder = () => import("../pages/MyOrder")
const GroupOrder = () => import("../pages/MyOrder/GroupOrder")
const Order = () => import("../pages/MyOrder/Order")
/* 给组件配置跳转路由地址 */
export default [
    /* 我的订单 */
    {
        path: "/myorder",
        component: MyOrder,
        children: [
            {
                path: "grouporder",
                component: GroupOrder
            },
            {
                path: "order",
                component: Order
            }
        ]
    },
    /* 交易信息页 */
    {
        path: "/trade",
        component: Trade
    },
    /* 支付页 */
    {
        path: "/pay",
        component: Pay
    },
    /* 支付成功页 */
    {
        path: "/paysuccess",
        component: PaySuccess
    },
    /* 购物车列表 */
    {
        path: "/shopcart",
        component: ShopCart
    },
    /* 添加购物车 */
    {
        path: "/addcartsuccess/:skuNum/:skuId",
        component: AddCartSuccess
    },
    /* 商品详情 */
    {
        path: "/detail/:skuId", //params 传参 
        component: Detail
    },
    /* 首页 */
    {
        path: "/home",
        component: Home
    },
    /* 登录 */
    {
        path: "/login",
        component: Login,
        /* 给路由设置属性 */
        meta: {
            // meta.isHidden为true时，跳转该路由，组件不显示
            isHidden: true
        }
    },
    /* 注册 */
    {
        path: "/register",
        component: Register,
        meta: {
            isHidden: true
        }
    },
    /* 搜索 */
    {
        name: "search",
        path: "/search/:keyword?",
        component: Search,
        //对象模式
        // props: route => ({
        //     keyword: route.query.keyword,
        //     categoryId: route.query.categoryId,
        //     categoryName: route.query.categoryName
        // })
    },
    /* 重定向路由 */
    {
        path: "/",
        redirect: "/home"
    }
]